import * as req from '@/request';

export async function list(
  params: { [key: string]: any },
  sorter?: { [key: string]: any },
  filter?: { [key: string]: any },
) {
  return req.postForm<API.ServiceTypeList>(
    '/servicetype/list',
    params,
    sorter,
    filter,
  );
}

export async function add(data: { [key: string]: any }) {
  return req.postForm<API.Result>('/servicetype/create', data);
}

export async function update(data: { [key: string]: any }) {
  return req.postForm<API.Result>('/servicetype/update', data);
}

export async function remove(data: { key: string }) {
  return req.post<API.Result>('/servicetype/delete', data);
}

export async function select(params: { [key: string]: any }) {
  const result = await req.get<API.ServiceTypeSelect>(
    '/servicetype/select',
    params,
  );

  if (result.success && result.data) {
    return Promise.resolve(result.data);
  }
  return Promise.resolve([]);
}
